feat(generator): support fuzzing max_priority_fee_per_gas#580
Open
op-will wants to merge 1 commit intoflashbots:mainfrom
Open
feat(generator): support fuzzing max_priority_fee_per_gas#580op-will wants to merge 1 commit intoflashbots:mainfrom
op-will wants to merge 1 commit intoflashbots:mainfrom
Conversation
Adds a per-tx EIP-1559 priority fee that can be set statically or
fuzzed via the existing fuzz mechanism:
- new field FunctionCallDefinition::max_priority_fee_per_gas (Option<String>,
may be a {placeholder}); plumbed through FunctionCallDefinitionStrict and
the templater
- new FuzzParam::max_priority_fee_per_gas (Option<bool>), mirroring the
existing FuzzParam::value flag; mutually exclusive with `param` and
`value`, with the conflict caught at scenario load time in parse_map_key
- complete_tx_request now raises max_fee_per_gas to match the priority fee
when the priority fee exceeds the sampled cap, preserving the EIP-1559
invariant
- docs/creating_scenarios.md documents both the static and fuzzed forms
- crates/core/CHANGELOG.md updated under [0.11.0]
c4aa6b6 to
ce92122
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The generator currently lets you fuzz function-call arguments and the tx
value, but there is no way to set or fuzzmax_priority_fee_per_gaspertx — every tx falls back to the global
gas_price / 10default.Solution
FunctionCallDefinition::max_priority_fee_per_gas: Option<String>— newfield on the user-facing scenario definition, plumbed through
FunctionCallDefinitionStrictand the templater so it lands on theTransactionRequest.FuzzParam::max_priority_fee_per_gas: Option<bool>— a flag that mirrorsthe existing
FuzzParam::valueflag, opting the priority-fee field intofuzzing for that entry. Mutually exclusive with
paramandvalue; theconflict is caught at scenario load time in
parse_map_key.TestScenarionow honors a per-tx priority fee if one is set(statically or via the fuzz path), falling back to the existing
gas_price / 10default otherwise.complete_tx_requestraisesmax_fee_per_gasto matchmax_priority_fee_per_gaswhen the priority fee exceeds the sampledcap, preserving the
max_fee_per_gas >= max_priority_fee_per_gasinvariant. Without this, a high fuzzed tip on a low-fee chain would
produce an invalid tx.
Example
Or pin a static priority fee:
See
docs/creating_scenarios.mdfor the full documentation.Breaking changes
Minor breaking change for downstream library users that construct
FuzzParamorFunctionCallDefinitionStrictvia struct literal:FuzzParamgains amax_priority_fee_per_gas: Option<bool>field.FunctionCallDefinitionStrictgains amax_priority_fee_per_gas: Option<String>field.FunctionCallDefinitionis unaffected for builder-style users(
FunctionCallDefinition::new(..).with_*(..)); the new field has adefault in the builder constructor.
Tests
function_def.rs: parses staticmax_priority_fee_per_gas, parses thefuzz flag, and confirms the
param+max_priority_fee_per_gascombination parses (so the runtime check in
parse_map_keyhas achance to run).
trait.rs:parse_map_keyroutesparam/value/max_priority_fee_per_gasto the correct fuzz-map keys and rejects every conflicting combination.
util.rs:complete_tx_requestusesgas_pricewhen the priorityfee is lower, raises
max_fee_per_gaswhen it's higher, handles theequal case, and the Eip4844 path inherits the same invariant.
PR Checklist
docs/creating_scenarios.md)cargo +nightly clippy --workspace --lib --examples --tests --benches --all-features --locked(-D warningsclean)cargo +nightly fmt --allcrates/core/CHANGELOG.mdupdated under## [0.11.0](matching the version already inCargo.toml)CHANGELOG.md— skipped per the note at the top of that file ("contender is now versioned by crate. This file will no longer be updated.")